float4x4 World;
float4x4 View;
float4x4 Projection;


struct PSO
{
    float4 Target0 : COLOR0;
    float4 Target1 : COLOR1;
    float4 Target2 : COLOR2;
};

struct VertexShaderInput
{
    float4 Position : POSITION0;
    float4 Normal : NORMAL0;
    float4 TexCoords : TEXCOORD0;
};

struct VertexShaderOutput
{
    float4 Position : POSITION0;
    float4 TexCoords : TEXCOORD0;
    float4 Normal : TEXCOORD1;
    float4 Wpos : TEXCOORD2;
};

VertexShaderOutput VS(VertexShaderInput input)
{
    VertexShaderOutput output;

    float4 worldPosition = mul(input.Position, World);
    float4 viewPosition = mul(worldPosition, View);
    float4 cameraPosition = mul(viewPosition, Projection);
    output.Position = mul(viewPosition, Projection);

    output.TexCoords = input.TexCoords;
    output.Normal = normalize(mul(input.Normal, World));
    output.Wpos = worldPosition;
    output.Wpos.w = cameraPosition.z / cameraPosition.w;

    return output;
}

PSO PS(VertexShaderOutput input) : COLOR0
{
    PSO output;

    output.Target0 = input.Wpos;
    output.Target1 = input.TexCoords;
    output.Target2 = input.Normal;

    return output;
}


technique Deferred
{
    pass Pass1
    {
        VertexShader = compile vs_3_0 VS();
        PixelShader = compile ps_3_0 PS();
    }
}